import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { inMeasuringEquipmentListData } from '/@/api/device.management/inMeasuringEquipment';

const { t } = useI18n('device.management.inMeasuringEquipment');

const modalProps = {
  title: t('检测设备表选择'),
};

const searchForm: FormProps = {
  baseColProps: { md: 8, lg: 6 },
  labelWidth: 90,
  schemas: [
    {
      label: t('所属企业code'),
      field: 'enterpriseId',
      component: 'Input',
    },
    {
      label: t('所属企业名称'),
      field: 'enterpriseName',
      component: 'Input',
    },
    {
      label: t('设备名称'),
      field: 'equipmentName',
      component: 'Input',
    },
    {
      label: t('设备类型'),
      field: 'equipmentType',
      component: 'Input',
    },
    {
      label: t('监测阈值-最小值'),
      field: 'thresholdValue',
      component: 'Input',
    },
    {
      label: t('监测阈值-最大值'),
      field: 'thremaxValue',
      component: 'Input',
    },
    {
      label: t('设备IMEI'),
      field: 'imei',
      component: 'Input',
    },
    {
      label: t('创建时间，保留2位小数'),
      field: 'createTime',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm',
        showTime: { format: 'HH:mm' },
      },
    },
    {
      label: t('更新时间'),
      field: 'updateTime',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm',
        showTime: { format: 'HH:mm' },
      },
    },
    {
      label: t('安装建筑ID'),
      field: 'buildId',
      component: 'Input',
    },
    {
      label: t('安装建筑名称'),
      field: 'buildName',
      component: 'Input',
    },
    {
      label: t('楼层'),
      field: 'floorNum',
      component: 'Input',
    },
    {
      label: t('区域ID'),
      field: 'regionId',
      component: 'Input',
    },
    {
      label: t('区域名称'),
      field: 'regionName',
      component: 'Input',
    },
    {
      label: t('经度'),
      field: 'longitude',
      component: 'Input',
    },
    {
      label: t('纬度'),
      field: 'latitude',
      component: 'Input',
    },
    {
      label: t('详细地址'),
      field: 'address',
      component: 'Input',
    },
    {
      label: t('示例图'),
      field: 'image',
      component: 'Input',
    },
    {
      label: t('是否为统计设备 01 是，02 为不是'),
      field: 'mark',
      component: 'Input',
    },
    {
      label: t('监测类型 01 喷淋泵压力 10 消火栓泵压力 20 最不利点消火栓压力 30 喷淋管网压力'),
      field: 'pressureType',
      component: 'Input',
    },
    {
      label: t('设备状态 01 正常 10 异常'),
      field: 'status',
      component: 'Select',
      componentProps: {
        dictType: 'sys_search_status',
        allowClear: true,
      },
    },
    {
      label: t('检测间隔'),
      field: 'jctime',
      component: 'Input',
    },
    {
      label: t('deleted'),
      field: 'deleted',
      component: 'Input',
    },
    {
      label: t('卡号'),
      field: 'cardCode',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('所属企业code'),
    dataIndex: 'enterpriseId',
    key: 'a.enterprise_id',
    sorter: true,
    width: 230,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('所属企业名称'),
    dataIndex: 'enterpriseName',
    key: 'a.enterprise_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('设备名称'),
    dataIndex: 'equipmentName',
    key: 'a.equipment_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('设备类型'),
    dataIndex: 'equipmentType',
    key: 'a.equipment_type',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('监测阈值-最小值'),
    dataIndex: 'thresholdValue',
    key: 'a.threshold_value',
    sorter: true,
    width: 130,
    align: 'right',
  },
  {
    title: t('监测阈值-最大值'),
    dataIndex: 'thremaxValue',
    key: 'a.thremax_value',
    sorter: true,
    width: 130,
    align: 'right',
  },
  {
    title: t('设备IMEI'),
    dataIndex: 'imei',
    key: 'a.imei',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('创建时间，保留2位小数'),
    dataIndex: 'createTime',
    key: 'a.create_time',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('更新时间'),
    dataIndex: 'updateTime',
    key: 'a.update_time',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('安装建筑ID'),
    dataIndex: 'buildId',
    key: 'a.build_id',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('安装建筑名称'),
    dataIndex: 'buildName',
    key: 'a.build_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('楼层'),
    dataIndex: 'floorNum',
    key: 'a.floor_num',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('区域ID'),
    dataIndex: 'regionId',
    key: 'a.region_id',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('区域名称'),
    dataIndex: 'regionName',
    key: 'a.region_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('经度'),
    dataIndex: 'longitude',
    key: 'a.longitude',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('纬度'),
    dataIndex: 'latitude',
    key: 'a.latitude',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('详细地址'),
    dataIndex: 'address',
    key: 'a.address',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('示例图'),
    dataIndex: 'image',
    key: 'a.image',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('是否为统计设备 01 是，02 为不是'),
    dataIndex: 'mark',
    key: 'a.mark',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('监测类型 01 喷淋泵压力 10 消火栓泵压力 20 最不利点消火栓压力 30 喷淋管网压力'),
    dataIndex: 'pressureType',
    key: 'a.pressure_type',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('设备状态 01 正常 10 异常'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_search_status',
  },
  {
    title: t('检测间隔'),
    dataIndex: 'jctime',
    key: 'a.jctime',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('deleted'),
    dataIndex: 'deleted',
    key: 'a.deleted',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('卡号'),
    dataIndex: 'cardCode',
    key: 'a.card_code',
    sorter: true,
    width: 130,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: inMeasuringEquipmentListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'tid',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'tid',
  itemName: 'tid',
  isShowCode: false,
};
